<template>
  <div class="coonterbox">
    <div class="title">
      <h1>{{ flag ? "企业信息" : "添加企业" }}</h1>
    </div>
    <div class="section" v-if="flag">
      <div class="firmbox">
        <img src="../../assets/images/IMG@2x.png" alt="" />
        <div class="firmtext">
          <h1>{{ information.ename }}</h1>
          <p>
            <el-button size="mini" plain v-if="information.status == 0">未审核</el-button>
            <el-button type="success" size="mini" plain v-if="information.status == 1">已审核</el-button>
            <el-button type="danger" size="mini" plain v-if="information.status == 2">已拒绝</el-button>
            <span style="color: #6b7280; margin-left: 20px">成立与2015年</span>
          </p>
        </div>
      </div>
      <div class="basicbox">
        <h1>基本信息</h1>
        <div class="basicinfor">
          <span class="basictitle" style="color: #6b7280">企业规模：</span>
          <span style="margin-right: 100px">500-1000人&nbsp; &nbsp;</span>
          <span class="basictitle" style="color: #6b7280">所属行业：</span>
          <span>{{ information.type }}</span>
        </div>
        <div class="basicinfor">
          <span class="basictitle" style="color: #6b7280">注册资金：</span>
          <span style="margin-right: 100px">5000万人民币</span>
          <span class="basictitle" style="color: #6b7280">成立时间：</span>
          <span>{{ information.createtime }}</span>
        </div>
      </div>
      <div class="provebox" v-show="information.url">
        <h1>企业资质证明</h1>
        <div class="imgbox">
          <img :src="'http://' + information.url" alt="" />
        </div>
      </div>
      <div class="contactbox">
        <h1>联系信息</h1>
        <div class="informationbox">
          <div class="inforleft">
            <p>
              <span class="intitle">联系人：</span>
              <span>{{ information.realname }}</span>
            </p>
            <p>
              <span class="intitle">企业地址：</span>
              <span>{{ information.address }}</span>
            </p>
            <p>
              <span class="intitle">电子邮箱：</span>
              <span><a href="#;">{{ information.email }}</a></span>
            </p>
          </div>
          <div class="inforight">
            <p>
              <span class="intitle">联系电话：</span>
              <span>
                <a href="#;">{{ information.phone }}</a></span>
            </p>
          </div>
        </div>
      </div>
    </div>
    <div v-if="!flag">
      <AddFrom></AddFrom>
    </div>
  </div>
</template>

<script>
import AddFrom from "@/components/addFrom/index.vue";
import { getlist, passaudit } from "@/api/enterprise/index";
export default {
  components: {
    AddFrom,
  },
  data() {
    return {
      information: {},
      flag: true,
    };
  },
  mounted() {
    this.getID();
  },
  methods: {
    getID() {
      getlist().then((res) => {
        console.log(res.data, "000000000000");
        this.information = res.data.records[0];
        this.realname = res.data.realname;
        if (res.data.records[0] == null) {
          this.flag = false;
          console.log(32984723);
        }
      });
    },
    handlepass() {
      const passobj = {
        status: 1,
        id: this.information.id,
      };
      this.$confirm("通过审核", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "success",
      })
        .then(() => {
          passaudit(passobj).then((res) => {
            this.$message({
              type: "success",
              message: "审核成功!",
            });
            this.getID();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消审核",
          });
        });
    },
    handlerefused() {
      const passobj = {
        status: 2,
        id: this.information.id,
      };
      this.$confirm("拒绝审核", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          passaudit(passobj).then((res) => {
            this.$message({
              type: "danger",
              message: "拒绝成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消审核",
          });
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.coonterbox {
  min-height: 100vh;
  background-color: #f9fafb;

  .title {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    box-sizing: border-box;
    background-color: #fff;

    h1 {
      width: 100%;
      text-align: center;
      font-size: 18px;
      font-weight: 550;
    }
  }

  .section {
    padding: 20px;

    .firmbox {
      display: flex;
      background-color: white;
      padding: 0px 10px;
      height: 100px;
      align-items: center;
      border-radius: 10px;

      img {
        width: 64px;
        height: 64px;
        margin-right: 30px;
      }

      .firmtext {
        h1 {
          font-size: 20px;
          font-weight: 600;
        }
      }
    }

    .basicbox {
      background-color: white;
      padding: 20px;
      margin-top: 20px;
      border-radius: 10px;

      h1 {
        font-size: 20px;
        font-weight: 600;
      }

      .basicinfor {
        height: 50px;
        line-height: 50px;
      }
    }

    .provebox {
      background-color: white;
      padding: 20px;
      margin-top: 20px;
      border-radius: 10px;

      h1 {
        font-size: 20px;
        font-weight: 600;
      }

      .imgbox {
        img {
          width: 200px;
          margin-top: 20px;
          margin-right: 20px;
        }
      }
    }

    .contactbox {
      background-color: white;
      padding: 20px;
      margin-top: 20px;
      border-radius: 10px;

      h1 {
        font-size: 20px;
        font-weight: 600;
      }

      .informationbox {
        width: 100%;
        display: flex;

        div {
          width: 49%;

          p {
            .intitle {
              color: #6b7280;
            }

            a {
              text-decoration: none;
            }
          }
        }
      }
    }
  }
}

.footer {
  display: flex;
  justify-content: right;
  padding: 20px;
}
</style>